import java.util.*;

public class Test {
    //集合
    //给你两个集合，要求{A} + {B}。 注：同一个集合中不会有两个相同的元素。
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        TreeSet<Integer> set = new TreeSet<Integer>();
        while (in.hasNext()) {
            int m = in.nextInt();
            int n = in.nextInt();
            for (int i = 1; i <= m + n; i++) {
                set.add(in.nextInt());
            }
            Iterator<Integer> it = set.iterator();
            while (it.hasNext()) {
                System.out.print(it.next());
                if (it.hasNext())
                    System.out.print(" ");
            }
        }
    }
}
